$("#connectForm #connect").click(function(){
	login();
});
$("#connectForm").keypress(function(e) {
	if(e.which == 13) {
		login();
	}
});

function login()
{
	$.ajax({
		type: "POST",
		url: "jqt/Connexion.jqt.php",
		dataType: "json",
		data: { user: $("#userConnect").val(), pass: $("#passConnect").val()}
	}).done(function(data) {
		console.log(data);
		if(data[0] == "PARAM_MISSING" || data[0] == "PARAM_EMPTY")
		{
			//console.log("Paramètres manquants");
			$(function() {
				new jBox("Notice", {
					content: "Paramètres manquants",
					color: "red",
					 delayClose: 1500
				});
			});
		}
		else if(data[0] == "BAD_AUTH")
		{
			$(function() {
				new jBox("Notice", {
					content: "Identifiants ou mot de passe incorrect",
					color: "red",
					 delayClose: 1500
				});
			});
		}
		else
		{
			window.location.href = "Connexion.php?user="+data[1]+"&sess="+data[2];
		}
	});
}